package com.ideaction.entity.player;


import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ideaction.req.BaseReq;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.mongodb.core.mapping.Document;

@Getter
@Setter
@ToString
@Document
public class Player {
    
    @JsonIgnore
    private String _id;//数据库 objectId 字符串
    
    private String userId;
    
    private String userName;// 玩家名字
    
    private long createTime;
    
    private long loginTime;
    
    private long saveTime;
    
    private String platform;// 平台
    
    private String channel;// 渠道
    
    private String version;// 版本
    
    private String ip;
    
    /**
     * playerClientData 对应为JSONObject,目的为了服务器不用关心客户端字段变化,当服务器需要哪些字段，自己去取 比如:
     * playerClientData.getString("name")
     * playerClientData.getInt("pveLevel")
     */
    private JSONObject playerClientData;
    
    private String realName;//真实姓名
    
    private String realID;//真实身份证号
    
    private String phoneNum;//手机号
    
    public Player() {
    
    }
    
    public Player(String userId, String ip, BaseReq baseReq) {
        long now = System.currentTimeMillis();
        this.ip = ip;
        this.createTime = now;
        this.loginTime = now;
        this.saveTime = now;
        this.userId = userId;
        this.platform = baseReq.getParam("Platform");
        this.channel = baseReq.getParam("Channel");
        this.version = baseReq.getParam("Version");
    }
    
}
